<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
　　
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>项目管理界面</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
    <script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/cr_page.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/cr.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
<div class="container" id="newp" style="width:60%;">
    <div style="width: 130px;height: 130px;background-color:whitesmoke;border-radius: 50%;margin-left:40%;vertical-align: middle;padding-top: 20px">
    <h2 style="text-align: center;">我的项目</h2></div>
    <div class="row"style="margin-top: 50px;" >
        <table class="table table-striped table-bordered">
            <thead>
            <tr>
                <td style="width: 60%" >项目名称</td>
                <td style="width: 40%">相关操作</td>
            </tr>
            </thead>
            <tbody id="pmsg" ></tbody>
        </table>
		 <div class="container" style="width:187px;">
            <div class="btn-group" id="pageBtn">
                <button type="button" class="btn btn-default"><span style="display:inline-block;width:14px;height:14px;background: url(/images/button.png) no-repeat -52px -8px;float:left;"></span></button>
				<button type="button" class="btn btn-default"><span style="display:inline-block;width:14px;height:14px;background: url(/images/button.png) no-repeat -14px -8px;float:left;"></span></button>
				<button type="button" class="btn btn-default"><span style="display:inline-block;width:14px;height:14px;background: url(/images/button.png) no-repeat -128px -8px;float:left;"></span></button>
				<button type="button" class="btn btn-default"><span style="display:inline-block;width:14px;height:14px;background: url(/images/button.png) no-repeat -91px -8px;float:left;"></span></button>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    var page = 1;
    var nextPage = "";
    var prePage = "";
    var lastPage = "";
    var btnDoms = $("#pageBtn").children();
    $(function() {
        getjob();
    });
    function checkMsg(dom){
        var tdDom = $(dom).parent().parent().children();
        console.log(tdDom);
        var jname = tdDom[0].innerHTML;
        window.location.href='../schemes.jsp?jname='+jname;
    }

       /**function alterMsg(dom) {
           //拿到当前被编辑的项目的所有信息
           var tdDom = $(dom).parent().parent().children();
           var jobId = tdDom[0].innerHTML;
           var userid = tdDom[1].innerHTML;
           var jname = tdDom[2].innerHTML;
           var filename = tdDom[3].innerHTML;
           var originphoto = tdDom[4].innerHTML;
           var histo = tdDom[5].innerHTML;

           if (roleid == "管理员") {
               $("#roleid option").eq(1).attr("selected", "selected").siblings().removeAttr("selected");
           }
           ;
           if (roleid == "车主") {
               $("#roleid option").eq(2).attr("selected", "selected").siblings().removeAttr("selected");
           }
           ;
           if (roleid == "坐席") {
               $("#roleid option").eq(3).attr("selected", "selected").siblings().removeAttr("selected");

           }
           ;
           if (roleid == "保安") {
               $("#roleid option").eq(4).attr("selected", "selected").siblings().removeAttr("selected");
           }
           $("#userid").val(userId);
           $("#username").val(username);
           $("#adress").val(adress);
           $("#plate").val(plate);
           $("#name").val(name);
           $("#phoneNumber").val(phoneNumber);
           $("#code").val(code);
           $("#codeImg").attr("src", "/SecurityTest/images/uploadFile/" + codeurl);
           $("#carImg").attr("src", "/SecurityTest/images/uploadFile/" + carurl);
           $("#alterPasswsord").fadeIn();
       };**/
       //删除用户
       function deleteUser(dom) {

           var flag = confirm("确认要删除么？");
           if (flag) {

               var tdDom = $(dom).parent().parent().children();
               console.log(tdDom);
               var jname = tdDom[0].innerHTML;
               console.log(jname);
               $.ajax({
                   type: "get",
                   dataType: 'json',
                   url: "/job/delete_job?jname=" + jname,
                   success: function (data) {
                       if (data.msg == "success") {
                           //删除成功之后返回新的项目列表；
                           getjob();
                       } else if (data.msg == "error") {
                           alert("删除项目失败！");
                       }
                   }
               });
           }
       }

       //获取所有项目信息
       function getjob() {
           $.ajax({
               type: "get",
               url: "/job/all_job",
               success: function (data) {
                   var jsonArr = data.Alljobs;
                   var html = "";
                   for (var i = jsonArr.length - 1; i > -1; i--) {
                       var data = jsonArr[i];
                       html += "<tr>" +
                               "	<td>" + data.jname + "</td>" +
                               "	<td><a href='javascript:void(0);' onclick='checkMsg(this);'> 查看详情 </a>/<a href='javascript:void(0);' onclick='deleteUser(this);'>删除</a></td>" +
                                "</tr>,";
                    }
                    cr_page($("#pmsg"), $("#pageBtn"), html, ",");
                    $("#pmsg").html(firstTen);
                }
            });
        }

</script>
</body>

</html>